/**
 * Copyright 2005 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.edi.runtime.component
{
	import com.edi.runtime.Event.*;
	
	import mx.controls.Image;

	/**
	 * 继承自Image，并实现了IEDIComponent 借口 
	 * 
	 */	
	public class EDIImage extends Image  implements IEDIComponent
	{
		private var _field:String;
		private var _table:String;
		private var _primaryKey:String="";
		private var _fieldLength:int;
		private var _fieldtype:String;
		private var _source:Object;
		
		/**
		 * 构造EDIImage 
		 * 
		 */		
		public function EDIImage()
		{
			super();
		}
		/**
		 * 实现IEDIComponent接口的属性，设置表名。 
		 * @param value 表名
		 * 
		 */	
		public function set table(value:String):void
		{
			_table=value;
			EDIEventProxy.listenerDataRolling(value,this);
		}
		public function get table():String
		{return _table;}
		
		
		override public function set source(value:Object):void
		{
			_source=value;
			super.source=value;
		} 
		
		override public function get source():Object
		{
			return _source;
		}
		
		
		/**
		 *  实现IEDIComponent接口的属性，设置是否是主键
		 * @param value
		 * 
		 */	
		public function set primaryKey(value:String):void{_primaryKey=value;}
		public function get primaryKey():String{return _primaryKey;}
		/**
		 *  实现IEDIComponent接口的属性，设置字段名
		 * @param value
		 * 
		 */	
		public function set field(value:String):void{_field=value;}
		public function get field():String{return _field;}
		/**
		 *  实现IEDIComponent接口的属性，设置字段类型
		 * @param value
		 * 
		 */
		public function set fieldType(value:String):void{_fieldtype=value;}
		public function get fieldType():String{return _fieldtype;}
		/**
		 * 实现IEDIComponent接口的属性，设置字段长度
		 * @param value
		 * 
		 */	
		public function set fieldLength(value:int):void{_fieldLength=value;}
		public function get fieldLength():int{return _fieldLength;}
		/**
		 * 实现IEDIComponent接口的属性，捕获数据滚动
		 * @param event
		 * 
		 */	
		public function dataRollingHandler(event:EDIDataEvent):void
		{
			source=event.value[_field].toString();
		}
		/**
		 * 返回数据监听时所需要的值 
		 * @return 
		 * 
		 */	
		public function get ediValue():String
		{
			return _source.toString();
		}
	}
}